Skip to content

feat: add workflow for blast radius api (CM-1328)#4372

Merged
ulemons merged 5 commits into
mainfrom
feat/add-temporal-blast-radious
Jul 21, 2026
Merged

feat: add workflow for blast radius api (CM-1328)#4372
ulemons merged 5 commits into
mainfrom
feat/add-temporal-blast-radious

Conversation

@ulemons

@ulemons ulemons commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the first slice of the Blast Radius feature: a POST /akrites-external/blast-radius/jobs
endpoint that accepts a request to analyze the blast radius of an advisory (optionally scoped
to a single package), and an on-demand Temporal workflow (analyzeBlastRadius, running on a new
blast-radius-worker task queue in packages_worker) that it triggers. There is no reachability
pipeline yet — every submission is accepted (202, status: pending), but the workflow
immediately fails with a non-retryable ECOSYSTEM_NOT_SUPPORTED error, since the real analysis
isn't implemented. This PR only stands up the request/trigger plumbing end-to-end; the pipeline,
persistence, and poll endpoint land in follow-up PRs.

Changes

  • New POST /akrites-external/blast-radius/jobs endpoint (submitBlastRadiusJob.ts), validated
    with a dedicated Zod schema (blastRadius.ts); always exactly one job per request (advisory-wide
    if package is omitted).
  • Ecosystem allow-list at the API layer: only ecosystem === 'npm' is accepted; anything else
    (including a missing/null ecosystem) is rejected with a 400 before the Temporal workflow is
    triggered, so no workflow run is ever spawned for unsupported ecosystems.
  • New on-demand Temporal workflow analyzeBlastRadius in packages_worker/src/blast-radius/, on
    its own blast-radius-worker task queue. It currently has no reachability pipeline — it always
    throws a non-retryable ECOSYSTEM_NOT_SUPPORTED ApplicationFailure (even for npm), built by a
    small pure helper (ecosystemSupport.ts) kept outside the workflow function so it's testable
    without the Temporal workflow sandbox.
  • Two ecosystem checks, two different jobs: the API-layer allow-list (npm-only, reject
    everything else at 400) is a request-validation gate; the workflow-layer rejection is
    unconditional (fires for npm too) because the actual pipeline doesn't exist yet. These will
    reconcile once the pipeline lands — not a bug, a deliberate interim state for this PR slice.
  • Shared workflow-input type ITriggerBlastRadiusAnalysis and TemporalWorkflowId.BLAST_RADIUS_ANALYSIS
    added to @crowd/types, mirroring the existing ITriggerCSVExport pattern.
  • New dedicated, env-configurable rate limiter for this endpoint only (AKRITES_BLAST_RADIUS_RATE_LIMIT_MAX
    / _WINDOW_MS, default 5 req/hour) plus the existing requireScopes([SCOPES.READ_PACKAGES]) check
    — reusing READ_PACKAGES as an interim scope until Auth0 issues a dedicated read:advisories scope.
  • New blast-radius-worker entrypoint, package.json dev/start scripts, and local-dev docker-compose
    service manifest, following the same pattern as the existing osv-worker/maven-worker workers.
  • openapi.yaml updated to document the new endpoint, including the 400 for unsupported ecosystem.
  • Out of scope for this PR (follow-up work): DB persistence of analysis jobs, the GET poll endpoint,
    7-day result caching, the real reachability pipeline, and creating the blast-radius-worker
    Kubernetes Deployment needed for actual staging/production rollout (kubectl set image only swaps
    the image tag on an existing Deployment — it doesn't create one).

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Performance improvement
  • Chore / dependency update
  • Documentation

JIRA ticket

CM-1328

@ulemons ulemons self-assigned this Jul 21, 2026
@ulemons ulemons added the Feature Created by Linear-GitHub Sync label Jul 21, 2026
Copilot AI review requested due to automatic review settings July 21, 2026 11:10
@cursor

cursor Bot commented Jul 21, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
New authenticated external endpoint that starts Temporal workflows per request; misconfiguration of namespace/task queue or rate limits could affect availability, but there is no persistence or real analysis yet.

Overview
Adds Blast Radius submit (2a) to the Akrites external API: POST /akrites-external/blast-radius/jobs accepts a GHSA/CVE advisory (optional package, npm-only ecosystem), returns 202 with a pending job, and starts analyzeBlastRadius on the packages Temporal namespace via blast-radius-worker.

The route uses a dedicated stricter rate limit (default 5/hour, env-tunable) and interim read:packages scope; OpenAPI documents request/response shapes and current limitations (no poll, cache, or real pipeline).

packages_worker gains a new worker entrypoint, docker/build wiring, shared ITriggerBlastRadiusAnalysis / workflow ID types, and a stub workflow that always fails with non-retryable ECOSYSTEM_NOT_SUPPORTED until reachability analysis exists. API validation rejects non-npm ecosystems before any workflow is started.

Unit tests cover Zod validation, the handler, and the failure helper; root vitest adds a @/ alias for backend tests.

Reviewed by Cursor Bugbot for commit cd4f5b6. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons
ulemons force-pushed the feat/add-temporal-blast-radious branch from 7cd58ae to fd4f294 Compare July 21, 2026 11:11

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fd4f294. Configure here.

Comment thread backend/src/api/public/v1/packages/submitBlastRadiusJob.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the initial Blast Radius API and Temporal workflow plumbing; analysis currently fails intentionally until the pipeline is implemented.

Changes:

  • Adds validated, authenticated, rate-limited job submission.
  • Adds shared Temporal types and a dedicated worker.
  • Adds tests, OpenAPI documentation, and local/build configuration.

Reviewed changes

Copilot reviewed 16 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
services/libs/types/src/temporal/index.ts Exports blast-radius types.
services/libs/types/src/temporal/blastRadius.ts Defines workflow input.
services/libs/types/src/enums/temporal.ts Adds workflow ID.
services/apps/packages_worker/src/workflows/index.ts Exports the workflow.
services/apps/packages_worker/src/blast-radius/workflows.ts Implements the temporary failing workflow.
services/apps/packages_worker/src/blast-radius/ecosystemSupport.ts Builds non-retryable failures.
services/apps/packages_worker/src/blast-radius/__tests__/ecosystemSupport.test.ts Tests failure construction.
services/apps/packages_worker/src/bin/blast-radius-worker.ts Adds worker entrypoint.
services/apps/packages_worker/package.json Adds scripts and types dependency.
scripts/services/blast-radius-worker.yaml Adds local Compose services.
scripts/builders/packages.env Includes the worker image.
pnpm-lock.yaml Updates workspace dependency resolution.
backend/src/api/public/v1/packages/submitBlastRadiusJob.ts Starts jobs and returns 202.
backend/src/api/public/v1/packages/submitBlastRadiusJob.test.ts Tests submission behavior.
backend/src/api/public/v1/packages/blastRadius.ts Defines validation and response types.
backend/src/api/public/v1/packages/blastRadius.test.ts Tests schema and mapping helpers.
backend/src/api/public/v1/akrites-external/openapi.yaml Documents the endpoint.
backend/src/api/public/v1/akrites-external/index.ts Registers auth, limiting, and routing.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/src/api/public/v1/packages/submitBlastRadiusJob.ts Outdated
Comment thread backend/src/api/public/v1/akrites-external/openapi.yaml Outdated
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings July 21, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 19 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (2)

backend/src/api/public/v1/packages/submitBlastRadiusJob.ts:35

  • This starts the workflow through the API's default Temporal client, but blast-radius-worker polls CROWD_PACKAGES_TEMPORAL_NAMESPACE. Those namespaces are explicitly separate in backend/src/db/packagesTemporal.ts:8-11, so in deployed environments this run will remain queued instead of reaching the new worker. Obtain the client with getPackagesTemporalClient() and start the workflow through it; update the handler test to mock that client.
  await req.temporal.workflow.start('analyzeBlastRadius', {

backend/src/api/public/v1/akrites-external/openapi.yaml:388

  • The runtime rejects both omitted/null ecosystems and every value except npm, but this request schema advertises ecosystem as optional and nullable. Generated clients can therefore send requests that are guaranteed to receive 400. Make the field required, non-nullable, and constrain it to the documented allow-list.
        ecosystem:
          type: string
          nullable: true
          description: Optional, only meaningful alongside package.

Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings July 21, 2026 11:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 19 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (1)

backend/src/api/public/v1/akrites-external/openapi.yaml:422

  • This documents an impossible response: requests without ecosystem are rejected before the handler runs, and accepted responses always echo npm. Remove nullable: true and the sentence claiming it can be null so generated clients match runtime behavior.
        ecosystem:
          type: string
          nullable: true
          description: Echoes the request's ecosystem. Null when the request omitted it.

Comment thread backend/src/api/public/v1/packages/blastRadius.ts Outdated
Comment thread backend/src/api/public/v1/packages/blastRadius.ts Outdated
Comment thread backend/src/api/public/v1/packages/blastRadius.ts Outdated
Comment thread backend/src/api/public/v1/akrites-external/index.ts
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Copilot AI review requested due to automatic review settings July 21, 2026 13:01
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 19 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread backend/src/api/public/v1/packages/submitBlastRadiusJob.ts Outdated
Comment thread pnpm-lock.yaml
Copilot AI review requested due to automatic review settings July 21, 2026 13:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 17 out of 19 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

Comment thread backend/src/api/public/v1/packages/blastRadius.ts
@ulemons
ulemons merged commit 6d840a9 into main Jul 21, 2026
16 of 17 checks passed
@ulemons
ulemons deleted the feat/add-temporal-blast-radious branch July 21, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants